package org.idea.spring.ioc.jndi.interfaces.impl;

import org.idea.spring.ioc.jndi.interfaces.LogService;

import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author idea
 * @Date created in 3:19 下午 2020/4/19
 */
public class SimpleLogService implements Referenceable, LogService {

    private SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public void log(String message) {
        String date=sdf.format(new Date());
        System.out.println(date+":"+message);
    }

    @Override
    public Reference getReference() throws NamingException {
        return new Reference(getClass().getName(),SimpleLogServiceFactory.class.getName(),null);
    }
}
